
$(function(){
    var menucont = $('.menucont');
    var menu = $('#menu');
    var next_btn = $('#menu_next');
    var prev_btn = $('#menu_prev');
    var tempw = menucont.width();
    if(menucont.width() < menu.width()){
        next_btn.show();
    }
    next_btn.click(function(){
        if(tempw < menu.width()){
            menu.animate({left:'-=83'},300,function(){
                tempw += 83;
                if(tempw > menu.width()) next_btn.hide();
            });
           prev_btn.show(); 
        }
        
    });
    prev_btn.click(function(){
        if(tempw > menucont.width()){
            menu.animate({left:'+=83'},300,function(){
                tempw -= 83;
                if(tempw == menucont.width()) prev_btn.hide();
            });
            next_btn.show();
        }
    });
});
$('.menu-list a').live('click',function(){
	//alert(1);
	var menu_text = $(this).text();
	var menu_href = $(this).attr('href');
	if ($('#tt').tabs('exists', menu_text)){
        $('#tt').tabs('select', menu_text);
        //refreshTab({tabTitle:menu_text,url:menu_href});
       // console.log("已打开")
    }else {
    	if (menu_href){
            var content = '<iframe scrolling="no" frameborder="0"  src="'+menu_href+'" style="width:100%;height:100%;"></iframe>';
        } else {  
            var content = '未实现';  
        } 
        console.log(menu_href);
        $('#tt').tabs('add',{  
            title:menu_text,  
            closable:true,  
            content:content
           //iconCls:icon||'icon-default'  
        });
		// $('#tt').tabs('add',{
		// 		title: menu_text,
		// 		href: menu_href,
		// 		closable:true
		// });
        console.log("打开");
	}
	return false;
});
function refreshTab(cfg){  
    var refresh_tab = cfg.tabTitle?$('#tt').tabs('getTab',cfg.tabTitle):$('#tt').tabs('getSelected');  
    if(refresh_tab && refresh_tab.find('iframe').length > 0){  
	    var _refresh_ifram = refresh_tab.find('iframe')[0];  
	    var refresh_url = cfg.url?cfg.url:_refresh_ifram.src;  
	    //_refresh_ifram.src = refresh_url;  
	    _refresh_ifram.contentWindow.location.href=refresh_url;  
    }
    return false;  
}